package edu.hawaii.duedates.book;

import java.io.Serializable;
import java.util.Comparator;

/**
 * Comparator class used to sort a Collection by due date.
 * 
 * @author John Zhou
 */
public class DueDateComparator implements Comparator<Object>, Serializable {

  private static final long serialVersionUID = 1L;

  /**
   * Override compare so that BorrowedItem can be sorted by due date.
   * 
   * @param obj1 The first Book object to be sorted.
   * @param obj2 The second Book object to be sorted.
   * @return A negative, zero, or a positive integer corresponding to less than, equal to, or
   * greater than.
   */
  public int compare(Object obj1, Object obj2) {
    Book a = (Book) obj1;
    Book b = (Book) obj2;
    return a.getDueDate().compareTo(b.getDueDate());
  }
}